package com.tsh.erp.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import kiven.jee.utils.common.Constants;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SessionHandlerInterceptor extends HandlerInterceptorAdapter {
	
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		boolean flag = false;

		if (request.getSession() != null
				&& request.getSession().getAttribute(Constants.AUTH_USER) != null) {
			flag = true;
		} else {
			response.sendRedirect(request.getContextPath() + "/");
		}

		return flag;
	}
}
